<?php

include_once('Resp.php');

class Regular {

    /**
     * @param $email
     * @return bool
     */
    public static function regEmail($email) {

        if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
            return true;
        }
        return false;
    }

    /**
     * @param $phone
     * @return bool
     */
    public static function regPhone($phone) {

        $len = strlen($phone);
        if ($len != 11) {// is not 11 bit count
            echo Resp::retFail(0, 'param error : '.$phone.' length is '.$len.' not 11 !');
            return true;
        }
        if(!preg_match("/^1[3|4|5|7|8][0-9]{9}$/", $phone)){// is not right format
            echo Resp::retFail(0, 'param error : '.$phone.' format is not right !');
            return true;
        }
        return false;
    }

}
